﻿using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using appladen.contracts;
using appladen.gui.ViewModels;

namespace appladen.gui
{
    /// <summary>
    ///   Interaction logic for View.xaml
    /// </summary>
    public partial class View : Window, IView
    {
        public View()
        {
            InitializeComponent();
        }

        #region IView Members

        public void Inject(IViewmodel independent)
        {
            DataContext = independent;
        }

        public void Run(params string[] args)
        {
            Trace.TraceInformation("View.Run");

            if (args.Length >= 1)
                ((IViewmodel) DataContext).ÖffneDatei(args[0]);
            ShowDialog();
        }

        #endregion

        private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var key = ((DataGrid) sender).SelectedIndex;
            ((IViewmodel)DataContext).DatensatzAnzeigen(key);
        }

     
        private void VorButton_Click(object sender, RoutedEventArgs e)
        {
            ((IViewmodel) DataContext).Vorwärts();
        }

        private void ZurückButton_Click(object sender, RoutedEventArgs e)
        {
            ((IViewmodel)DataContext).Rückwärts();
        }
    }
}